// 导入request 对象
import { request } from '@utils/http'
import React from 'react'
import { IHospitalBodyParams, IHospitalSetItem, IHospitalSetReqParams, IHospitalSetResponse } from './model/hospitalSetTypes'

/**
 * 获取医院设置列表数据
 * @param {page:当前页,limit:每页几条,hosname:医院名称, hoscode:医院编码}
 * @returns Promise<IHospitalSetResponse>
 */
export const getHospitalSetList = ({page,limit,hosname,hoscode}:IHospitalSetReqParams)=>{
    return request.get<any,IHospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`,{
        params:{
            hosname,
            hoscode
        }
    })
}
/**
 * 添加医院
 * @param hospitalSet 医院设置数据
 * @returns null
 */
export const addHospitalSet = async (hospitalSet:IHospitalBodyParams)=>{
    return request.post<any,null>('/admin/hosp/hospitalSet/save', hospitalSet)
}
/**
 * 根据id 删除医院设置
 * @param id 
 * @returns null
 */
export const deleteHospitalSetById = async (id:string)=>{
    return request.delete<any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}
/**
 * 根据id获取医院设置数据
 * @param id 
 * @returns 
 */
export const getHospitalSetById = async (id:string)=>{
    return request.get<any,IHospitalSetItem>('/admin/hosp/hospitalSet/get/' + id)
}
/**
 * 编辑医院数据
 * @param hospitalSet 
 * @returns Null
 */
export const editHospitalSet = async (hospitalSet:IHospitalSetItem)=>{
    return request.put<any,null>('/admin/hosp/hospitalSet/update',hospitalSet)
}
/**
 * 根据id的数组批量删除
 * @param selectedKeys 
 * @returns 
 */
export const batchRemove = async (selectedKeys:React.Key[])=>{
    return request.delete<any,null>('/admin/hosp/hospitalSet/batchRemove',{
        data:selectedKeys
    })
}